Repository navigation
dcp: speak the firmware-27 dptx-port interface and answer OOB service calls - #591
Conversation
9468348 to
b401a3c
Compare
b401a3c to
3c89289
Compare
… calls The T6050 DCP's firmware 27 hosts its dptx-port RemotePort service on endpoint 0x2c and announces no 0x2a, so dcp_dptx_init() waited on an endpoint that is not there. On that endpoint it also speaks a later message layout, and it makes its own service calls to the AP out of band: the request and the reply are in its buffers, named by address and length in the command, which AFK rejected. Endpoint: use 0x2a where the firmware announces it, as before, and 0x2c where it announces only that (rtkit_has_endpoint(), from the endpoint map the IOP sent). The endpoint is what selects the layout below; no chip or firmware version is checked. On that layout (dcp_dptx_if_t.v27): - the connection is validated before it is taken; - validate-connection and connect replies are eight bytes with no status word; the connect reply echoes the attributes it took, and a port behind a DP-to-HDMI converter does not claim supportsHPD (the AP reports that HPD); - request-display and the hotplug call return no status; hotplug echoes the state it took; - the firmware's group-1 link record calls (3 and 4) carry its own pointers and are returned as given with their result words cleared; drive settings come as a lane count at 16 (set) or 0 (get) and the lanes from 32, checked against DisplayPort's levels before the PHY sees them; tiling hints are a 160-byte record whose status is at 0x90; link fault reports are acknowledged, as on T8152. Out-of-band service calls (command flags bit 0), on any AFKv2 endpoint whose service takes calls: the request is copied from the firmware's tx buffer and the reply to its rx buffer only when every page of each is mapped in the session's DART and lands in RAM (rtkit_access_remote(), nothing is mapped for it), both are at most 16 KiB and the reply fits the command's capacity. The status goes back in the response's value; a failed call returns no bytes. Anything else is still refused as unsupported without touching a firmware address. Before this, every such call was refused. The AFKv2 command's tx buffer is cleaned to memory after it is written and its rx buffer invalidated before it is read, as the firmware's DMA needs on any machine where those buffers are cached. Signed-off-by: Satya Benson <satya@benson.earth>
3c89289 to
f7771e5
Compare
|
rebased onto fix/584-hdmi-route-adt 0b82cba: old head 3c89289, new head f7771e5, conflicts in src/dcp.c (dp2hdmi is set inside main's new dp2hdmi_gpio block), src/dcp/dptx_port_ep.c (main already adds drive[4] and the group-1 GetDriveSettings call; link fault reports are acked on T8152, T8103 or the v27 layout). |
|
J775c (M5 Max Studio) row for the rebased stack at these heads: #589 Stage 2: Linux: |
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: CHANGES REQUESTED at f7771e54
Blockers:
- Unaligned cache maintenance and destructive
dc_ivac_range()on firmware-supplied DVAs (src/rtkit.c:931-941):CACHE_RANGE_OP(src/memory.c:29-34) starts atu64 p = (u64)addrand loopswhile (p < p + length) { cacheop(op, p); p += 64; }without aligningpdown toCACHE_LINE_SIZE(64). Becausertkit_access_remote()accepts arbitrary firmware-supplieddvaoffsets, anypathat is not 64-byte aligned and crosses a 64-byte boundary (e.g.,pa = ...0x30,chunk = 24,end = ...0x48) advancespfrom...0x30to...0x70 >= endand skips the trailing cache line (...0x40), leaving stale bytes in AP cache on!to_iopreads and uncleaned tail bytes onto_iopwrites. Furthermore,dc_ivac_range()executes baredc ivac(invalidate without clean), which discards any adjacent dirty AP data sharing a partial boundary cache line with an unaligned firmware buffer. Align the cache-maintenance span down/up toCACHE_LINE_SIZE(64 bytes) and usedc_civac_range()(clean+invalidate) on the!to_iopread path. - Stacked on open PR
#590: targets feature branchfix/584-hdmi-route-adt(not yet merged tomain). - Pending T8152 regression row: the T8152 (J873g) HDMI/USB-C regression row noted under
Not yetis still outstanding (AFKv2 OOB service calls now dispatch to the handler on T8152 as well; exact-headf7771e54J775c HDMI + SLC row is posted and clean).
Checked:
- Audited all production changes (
src/afk.c,src/dcp.c,src/dcp.h,src/dcp/dptx_port_ep.c,src/rtkit.c,src/rtkit.h). - Verified
afkv2_handle_oob_command()validates packet size,AFKV2_OOB_MAX(16 KiB) bounds,oob->rxlen <= cmd->value, pre-checksrxbufDART/RAM containment before allocation, checks"ipcx"magic andcall->length, zeroespacket.oob.rxlenon error, and freesrequest/responseon all paths. - Verified
afkv2_copy_response()(dc_ivac_range) andafkv2_command()(dc_cvac_range) operate on page-alignedepic->rxbuf.bfr/epic->txbuf.bfr, so every cache line in[0, size)is covered there. - Verified
dcp_dptx_endpoint()selects0x2conly when0x2ais absent and0x2cis present in the endpoint map (rtkit_has_endpoint()),dptxport_call_v27()validates group-1 link record sizes, 160-byte tiled-display hints, and drive-setting bounds (voltage <= 3,pre_emphasis <= 3,voltage + pre_emphasis <= 3,count <= 4), anddptxport_connect()omitssupportsHPD(0x100) on v27dp2hdmiports while checking echoed attributes. - Verified
rtkit_remote_page()intentionally preserves high T6050 3-table IOVA bits (dva & ~rtk->dva_base) and validates full-span RAM bounds before reading/writing. - Hosted CI is green at
f7771e54(8/8checks passed:policy,ESP stage 2 vital size,selftest,pr-text,readiness).
Evidence
- Head SHA:
f7771e54317af9397da0f6720acf5ccf43bc2399(base=fix/584-hdmi-route-adt,MERGEABLE,8P/0F/0QCI). src/memory.c:29-34:CACHE_RANGE_OPstarts at unalignedu64 p = (u64)addr; u64 end = p + length; while (p < end) { cacheop(op, p); p += CACHE_LINE_SIZE; }withCACHE_RANGE_OP(dc_ivac_range, "dc ivac").- Exact-head J775c row (
#591#issuecomment-7283293452) confirmeddcp-dptx: endpoint 0x2c announces the dptx-port service,swap_id=0,HDMI-A-1 connected 2560x1440, SLC enabled on 32 planes, 0 failed units.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at f7771e54
Blockers:
src/dcp/dptx_port_ep.c:607: on a v27SET_DRIVE_SETTINGScall, onlydata_sizeis checked against32 + count * 12.reply_sizeis only checked to be at least 32. Line 624 then copiescount * 12bytes toreply + 32, so a call with 4 lanes and a 32-byte reply writes 48 bytes past the reply. On the out-of-band path that reply is thecalloc(oob->rxlen)buffer. Fix: checkreply_sizeon both paths, as main's group-1 handler does a few lines further down:count > ARRAY_SIZE(port->drive) || (set && data_size < 32 + count * sizeof(*port->drive)) || reply_size < 32 + count * sizeof(*port->drive).src/rtkit.c:934and:936: the cache maintenance misses the last line of a span that doesn't start on a 64-byte line.CACHE_RANGE_OP(src/memory.c:29) starts at the address it's given and steps by 64 whilep < end. For a firmware buffer at…0x30with 24 bytes, it cleans or invalidates the line at…0x00and stops, so the line at…0x40is never touched.dvacomes from the firmware here, so nothing guarantees alignment. The read path then copies a stale tail on the second call into a reused tx buffer, and the write path leaves the reply's tail in the AP cache. Fix: inrtkit_access_remote(), run the maintenance overALIGN_DOWN((u64)pa, 64)toALIGN_UP((u64)pa + chunk, 64). Or alignpdown inCACHE_RANGE_OP, which changes nothing for callers that are already aligned.- Row:
afkv2_handle_command()now sends every AFKv2 out-of-band call to the service's handler, not only the v27 endpoint's, so T8152 runs new code. The T8152 J873 HDMI and USB-C row from Not yet is needed before merge.
Checked: 0x2c is chosen only when the firmware's endpoint map has it and doesn't have 0x2a, and there's no chip check. Out-of-band buffers are capped at 16 KiB, every page is checked against the DART and RAM before use, the reply is checked against the command's capacity, the ipcx header and length are checked, and nothing is mapped. The group-1 link records and the tiling-hints record are bounds-checked. Drive levels are checked against DisplayPort's limits before the PHY sees them. The J775c row for the rebased stack is at this head.
Signed-off-by: Satya Benson <satya@benson.earth>
|
Merged main 2a7854a (via the branch below); one conflict resolved in src/dcp/dptx_port_ep.c: kept main's link-fault check, which already covers v27. |
…ache ops Validate reply_size against 32 + count * sizeof(*port->drive) on v27 SET_DRIVE_SETTINGS as well as GET_DRIVE_SETTINGS, preventing a short reply buffer from being overrun when echoing the lane settings. In rtkit_access_remote(), align cache maintenance spans down and up to 64-byte cache lines and use dc_civac_range() on the !to_iop read path so unaligned firmware DVAs never skip trailing cache lines or discard adjacent dirty AP data sharing a boundary line. Extend test_dptx_v27_oob.py to cover both cases. Signed-off-by: Satya Benson <satya@benson.earth>
Signed-off-by: Satya Benson <satya@benson.earth>
|
Addressed both code blockers at
Updated Stage 2 hardware row for J775c at this head will follow once the current build finishes. |
|
J775c (M5 Max) row: a Stage 2 built from aura main |
|
J775c (M5 Max Studio) Stage 2 hardware row at the updated heads: #591
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Both reported code failures are fixed at this head. The drive-settings handler checks the reply span on both paths, and remote cache maintenance covers both boundary lines of each span. The PR records a J775c stack row at the earlier fixed head.
|
Merging at |
What: The dptx-port service is started on endpoint 0x2c with the firmware-27 message layout when the DCP firmware announces 0x2c and not 0x2a (the T6050 DCP's does), and AFKv2 out-of-band service calls from the firmware are answered instead of refused. Before, aura waited on 0x2a, which that firmware does not have, and could not answer the firmware's PHY callbacks. Stacked on #590; refs #584.
Tested: one J775c row on the previous stack (#590 at 5b5765f) never started the dptx-port service: #590's route fell back to the internal engine. This PR's commit is unchanged, rebased onto #590's new head. No hardware row at this head. Host only:
tests/python/test_dptx_v27_oob.pybuilds the realrtkit_has_endpoint()/rtkit_access_remote()(over a model DART and RAM), the AFKv2 peer-command path ofsrc/afk.c, and the endpoint choice and v27 calls ofsrc/dcp/dptx_port_ep.cagainst stand-ins (ASan/UBSan); 4 tests, all fail on its base and pass here.Risk: two-way · every AFKv2 display firmware that sends out-of-band service calls (T6050, T8152): those were refused as unsupported and are now dispatched to the service's call handler with bounded, DART-checked buffers. The v27 layout only where the firmware announces 0x2c and not 0x2a (T6050). Every machine that announces 0x2a keeps it and its layout.
Not yet: a J775c HDMI row (dptx-port opens on 0x2c, connect, request-display and training callbacks succeed); a T8152 J873g HDMI and USB-C regression row, since its out-of-band calls now reach its handler.
Details
dcp_dptx_endpoint()uses 0x2a when the IOP's endpoint map has it, else 0x2c when it has that (rtkit_has_endpoint()), else 0x2a. The endpoint the firmware announced selects the layout; no chip or firmware version is checked.dcp_dptx_if_t.v27): validate-connection before connect; validate and connect replies of eight bytes without a status word; connect echoes the attributes it took, and a port behind a DP-to-HDMI converter does not claim supportsHPD (the AP reports it,dcp_dptx_needs_ap_hpd()); request-display and hotplug without status, hotplug echoing its state; group-1 link records (3, 4) returned with their result words cleared; drive settings as a lane count at 16 (set) or 0 (get) and lanes from 32, checked against DisplayPort's levels (swing and pre-emphasis 0..3, sum at most 3) before the PHY; a 160-byte tiling-hints record with its status at 0x90; link-fault reports acknowledged, as on T8152. The connect echo check is the same rule as display/dptx: don't reject a DPTX connect reply over the unk field #292's.afkv2_handle_oob_command()): request read from the firmware's tx buffer and reply written to its rx buffer throughrtkit_access_remote(), which requires every 16 KiB page of each span to be mapped in the session's DART and to land in RAM, maps nothing, and does the cache maintenance. Both buffers at most 16 KiB, the reply within the command's capacity, a valid service-call header. Status in the response's value; a failed call returns no bytes and keeps the descriptor. Anything else is still refused without touching a firmware address.tests/python/test_dcp_shutdown_failures.py: its interface stand-in gains the new field and endpoint choice.rtkit_access_remote()uses (a separate test commit on the trial stack).Evidence
Cases: endpoint map lookup; a two-page span with the DART's DRAM-mask bit, written and read back through two non-contiguous pages with cache maintenance; an unmapped page, a page outside RAM, empty, wrapping and DART-less spans refused with nothing copied. An out-of-band call dispatched with its group, command and length, its reply in the firmware's buffer and status 0; a failing call's status with no bytes; refused before the call when the reply exceeds the capacity, the reply buffer is unmapped, the request is short or its magic wrong. Endpoint choice for {0x2a, 0x2c}, {0x2c}, {}; group-1 records, other calls left to the common handler, tiling hints, drive settings set and read back, out-of-range levels and lane counts refused without a PHY call.
clang-format20.1.8 clean. ESP Stage 2 builds.